<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--服务商管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <link rel="stylesheet" href="__STATIC_URL__/static/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <link rel="stylesheet" href="__STATIC_URL__/static/css/addmchat.css"/>
    <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrapSwitch.css"/>
    <script src="__STATIC_URL__/static/jquery/2.2.1/jquery.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/js/bootstrapSwitch.js"></script>
    <script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>
    <script src="__STATIC_URL__/static/layer/layer.js"></script>

    <style>
        thead tr th {
            text-align: center;
        }

        tbody tr td {
            text-align: center;
        }

        .content .panel-search {
            border: 1px solid #d0f2f7;
        }

        .panel-default > .panel-heading {
            background: #EEF8FC;
            color: #26929C;
        }
    </style>
</head>
<body>
{include file='public/header'/}
<!------------------导航-------------------------->
<section id="content">
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading">
            <ul class="breadcrumb mgl15 mgr15">
                <li>当前位置是:</li>
                <li>
                    <a href="javascript:;">商户管理</a>
                </li>
                <li class="active" style="color: #02b87f;"> 商户列表</li>
            </ul>
        </div>
        <div class="panel panel-search panel-default mgl15 mgr15">
            <div class="panel-heading">
                <h3 class="panel-title">
                    <span class="glyphicon glyphicon-search pull-left" style="margin-right: 10px;"></span>筛选分类
                </h3>
            </div>
            <div class="panel-body">
                <form action="" method="get" class="form-horizontal table-search form-search" role="form" id="machform">
                    <div class="col-sm-6 col-md-6 col-lg-4 ">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">商户名称：</label>
                            <div class="col-sm-9">
                                <select name="merchant_name" id="" class="form-control">
                                    <option value="">所有商户</option>
                                    {volist name="momachlist" id="search"}
                                    <option value="{$search.merchant_name}" {if condition="$p_data['merchant_name'] eq $search.merchant_name"}selected{/if}>{$search.merchant_name}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="panel-footer">
                <a href="javascript:;" class="btn btn-primary" onclick="searchform()">查找</a>
                <a href="javascript:;" class="btn btn-default" onclick="clearform()">清空</a>
            </div>
        </div>
        <div class="panel panel-default mgl15 mgr15">
            <div class="panel-heading addCharts" style="background:#ededed;">商户列表</div>
            <div class="panel-body">
                <table class="table table-bordered" data-toolbar="#toolbar">
                    <thead>
                    <tr>
                        <th data-type="0">商户编号</th>
                        <th data-type="1">商户名称</th>
                        <th data-type="2">商户号</th>
                        <th>隶属服务商</th>
                        <th>业务员</th>
                        <if condition="(authcheck('momach/machxg',session('uid'))) or (authcheck('momach/delmach',session('uid')))">
                            <th>操作</th>
                        </if>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="momach" id="vo"}
                    <tr>
                        <td class="mid">{$vo.id}</td>
                        <td class="mid">
                            {$vo.merchant_name}
                        </td>
                        <td class="mid">
                            {if condition="$vo.shtd eq '0' "}
                            {$vo.sub_mch_id}
                            {elseif condition="$vo.shtd eq '1' "/}
                            {$vo.cmmb_mer_id}
                            {/if}
                        </td>
                        <td class="mid">{:getagent($vo['agent'],"name")}</td>
                        <td class="mid">{:getsales($vo['salesman'])}</td>
                        <td class="mid">
                            <a href="javascript:;" class="btn-link" onclick="show('{$vo.id}');">重置密码</a>&nbsp;&nbsp;|

                            <a href="{:url('momachtest/momachdevicegl',['id'=>$vo['id']])}" class="btn-link" >设备管理</a>&nbsp;&nbsp;|

                            {if condition="checkPath('momach/machlist')"}
                            <a class="btn-link" href="{:url('momach/machlist',['top_mid'=>$vo['id']])}"> 查看下级门店 |</a>
                            {/if}
                            {if condition="checkPath('momach/momachxg')"}
                            <a class="btn-link" href="{:url('momach/momachxg',['id'=>$vo['id']])}"> 修改|</a>
                            {/if}
                            {if condition="checkPath('momach/momachinfo')"}
                            <a class="btn-link" href="{:url('momach/momachinfo')}?id={$vo.id}"> 查看信息</a>
                            {/if}

                            {if condition="checkPath('momach/momachdel')"}
                            <a class="btn-link" onclick="return confirm('正在删除商户{$vo.merchant_name},删除后子门店将不可恢复是否继续删除')" href="{:url('momach/momachdel')}?id={$vo.id}""> &nbsp;| &nbsp;删除</a>
                            {/if}
                        </td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
            </div>
            {$momach->render()}
        </div>
        {include file='public/footer'/}
    </div>
</section>
<!-- 设备列表展示Modal 开始-->

<!-- 设备列表展示Modal 结束-->
<!-- 生成绑定吗 Modal 开始-->

<!-- 生成绑定吗 Modal 结束-->
<!-- 修改绑定退款密码Modal 开始-->

<!-- 修改绑定退款密码Modal 结束-->
<!-- 二维码下载模态框（Modal） 开始-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">×
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    二维码
                </h4>
            </div>
            <div class="modal-body">
                <ul id="myTab" class="nav nav-tabs">
                    {if condition="checkPath('mach/getmercode')"}
                    <li class="active tabhome">
                        <a href="#home" data-toggle="tab">
                            收款二维码
                        </a>
                    </li>
                    {/if}
                    {if condition="checkPath('mach/getqrcode')"}
                    <li class="tabios"><a href="#ios" data-toggle="tab">单独二维码</a></li>
                    {/if}
                </ul>
                <div id="myTabContent" class="tab-content">
                    {if condition="checkPath('mach/getmercode')"}
                    <div class="tab-pane fade in active text-center" id="home">
                        <img src="" alt="" style="width: 230px;"/>
                        <a href="" id="codeone" class="btn btn-primary">点击下载</a>
                    </div>
                    {/if}
                    {if condition="checkPath('mach/getqrcode')"}
                    <div class="tab-pane fade text-center" id="ios">
                        <img src="" alt=""/>
                        <a href="" id="codetwo" class="btn btn-primary"> 点击下载 </a>
                    </div>
                    {/if}
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default"
                        data-dismiss="modal">关闭
                </button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- 二维码下载模态框（Modal） 结束-->
<script src="__STATIC_URL__/static/js/clipboard.min.js"></script>
<!-- 是否重置该代理商密码（Modal） -->
<div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

            </div>
            <div class="modal-body"> <h4 class="modal-title" id="myModalLabel3">是否重置该用户密码</h4></div>

            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">否</button>
                <button type="button" class="btn btn-primary" id="btn-primary" data-id="">是</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>

            </div>
            <div class="modal-body" >

                <div class="form-group" style="    height: 33px;">
                    <label for="password" class="col-sm-2 control-label" style="margin-top: 9px;">账号</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="name" name="name" placeholder="请输入账号" value="" disabled>
                    </div>
                    <div class="col-sm-2" style="    margin-top: 5px;">
                        <a href="javascript:;" id="cname" data-clipboard-action="copy"
                           data-clipboard-text=""
                           class="copytext">点击复制</a>
                    </div>
                </div>
                <div class="form-group" style="  height: 33px;">
                    <label for="password" class="col-sm-2 control-label" style="margin-top: 9px;">密码</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" id="password" name="password" placeholder="请输入密码" value="" disabled>
                    </div>
                    <div class="col-sm-2" style="margin-top: 5px;">
                        <a href="javascript:;" id="cword" data-clipboard-action="copy" data-clipboard-text="" class="copytext">点击复制</a>                         </div>
                </div>
                <div class="checkbox">
                    <label><input type="checkbox" value="" name="pname" id="pname">我已保存该账号密码</label>
                </div>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="btn-default">提交更改</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<script>
    function show(name){
        $('#btn-primary').attr("data-id",name);
        $('#myModal3').modal('show')
    }
    $("#btn-primary").click(function(){
        $('#myModal3').modal('hide')
        $('#myModal1').modal('show')
        var username=$('#btn-primary').attr("data-id");
        $.ajax({
            url: "{:url('momach/resetpassword')}",
            type: 'POST',
            data: {
                id:username
            },
            success: function (data) {
                // console.log(data);
                $('#name').val(data.username);
                $('#cname').attr("data-clipboard-text",data.username);
                $('#password').val(data.new_password);
                $('#cword').attr("data-clipboard-text",data.new_password);
            }
        })
    });
    $("#btn-default").click(function(){
        var aaa = $("#pname").get(0).checked;
        // console.log(aaa);
        if(aaa==true){
            $('#myModal1').modal('hide')
        }else if(aaa==false){
            alert("请选中我已保存");
        };




    })

</script>

<script src="__STATIC_URL__/static/js/clipboard.min.js"></script>
<script>
    // $(function () {

    var clipboard =  new Clipboard('.copytext');

    clipboard.on('success', function (e) {
        layer.msg('复制成功');
    });

    clipboard.on('error', function (e) {
        layer.msg('复制失败');
    });
    // })
</script>
</body>
<script src="__STATIC_URL__/static/js/template.js"></script>

<script type="text/javascript">
    $(function () {
        $('#myModal').on('show.bs.modal', function () {
            var code = "{:checkPath('mach/qrcode')}";
            if(code == 0||code == ""){
                layer.alert("没有权限访问");
                return false;
            }
            var getmercode = "{:checkPath('mach/getmercode')}";
            var getqrcode = "{:checkPath('mach/getqrcode')}";
            if(getmercode=="" && getqrcode==""){
                layer.alert("没有权限访问");
                return false;
            }
            if(getmercode == 0 ){
                $(".tabios").addClass("active");
                $("#ios").addClass("active").addClass("in");
            }
            var url1 = $(event.target).data("urlone");
            var url2 = $(event.target).data("urltwo");
            $("#home img").attr("src", url1);
            $("#ios img").attr("src", url2);
            $("#codeone").attr("href", url1);
            $("#codetwo").attr("href", url2);
        })
        $('#myModal').on('hide.bs.modal', function () {
            $("#home img").attr("src", '');
            $("#ios img").attr("src", '');
        });
        $(".model").click(function (event) {
            var id = $(event.target).data("id");
            var name = $(event.target).data("name");
            layer.confirm('正在删除商户' + name + ',删除后将不可恢复\n是否继续删除', {
                btn: ['确认','取消'] //按钮
            }, function(){
                $.ajax({
                    url: "{:url('mach/delmach')}",
                    data: {
                        id: id
                    },
                    type: "post",
                    success: function (data) {
                        if(data.code==0){
                            layer.msg("删除成功", {icon: 1,time:1000});
                            setTimeout("window.location.reload()",1000);
                            return false;
                        }else{
                            layer.alert(data.message);
                            return false
                        }
                    }
                })
            }, function(){

            });
        })
    });

</script>

</html>
